package com.xayy.mgt.enums;

import lombok.Getter;

/**
 * 严重程度
 */
@Getter
public enum SeriousDegreeEnum {
    LOW(1, "轻微"),

    MEDIUM(2, "一般"),

    HIGH(3, "严重"),

    DEAD(4, "致命");


    private Integer level;
    private String name;

    SeriousDegreeEnum(Integer level, String name) {
        this.name = name;
        this.level = level;
    }

    public static String valueof(Integer index) {
        for (SeriousDegreeEnum seriousDegreeEnum : values()) {
            if (seriousDegreeEnum.getLevel() == index) {
                return seriousDegreeEnum.name;
            }
        }
        return "";
    }
    public static Integer valueof(String name) {
        for (SeriousDegreeEnum seriousDegreeEnum : values()) {
            if ( name.equals(seriousDegreeEnum.name())) {
                return seriousDegreeEnum.level;
            }
        }
        return null;
    }
}
